# -*- coding:utf-8 -*-
# @FileName  :role.py
# @Time      :2020/10/25 14:59
# @Author    :zhoujirong

from common.http_request import Request
from biz.support.urls import ServerUrl

class RoleRequest:
    @classmethod
    def role_add(cls,name,roleType,description,cookie):
       '''
       新增角色接口
       :param name: 角色名称
       :param roleType:  角色类型
       :param description: 角色描述
       :return:
       '''
       data = {
           'name': name,
           'roleType': roleType,
           'description': description
       }
       req = Request(ServerUrl.role_add_url, data=data,headers=cookie)
       return req.post()

    @classmethod
    def role_del(cls,ids,cookie):
        '''
        删除角色
        :param ids: 角色id，可以是列表
        :return:
        '''
        data = {
            'ids':ids
        }
        req = Request(ServerUrl.role_del_url,data=data,headers=cookie)
        return req.post()

    @classmethod
    def role_update(cls,createTime,createUser,createUsernickname,description,id,name,orgId,roleType,updateTime,updateUser,updateUsernickname,cookie):
        '''
        角色编辑接口
        :param createTime:
        :param createUser:
        :param createUsernickname:
        :param description:
        :param id:
        :param name:
        :param orgId:
        :param roleType:
        :param updateTime:
        :param updateUser:
        :param updateUsernickname:
        :param cookie:
        :return:
        '''
        data = {
            "createTime":createTime,
            "createUser":createUser,
            "createUsernickname":createUsernickname,
            "description":description,
            "id":id,
            "name":name,
            "orgId":orgId,
            "roleType":roleType,
            "updateTime":updateTime,
            "updateUser":updateUser,
            "updateUsernickname":updateUsernickname
        }
        req = Request(ServerUrl.role_update_url, data=data, headers=cookie)
        return req.post()

    @classmethod
    def role_getpage(cls,curPage,maxSize,search_LIKE_name,search_EQ_roleType,cookie):
        '''
        角色查询接口
        :param curPage:
        :param maxSize:
        :param search_LIKE_name: 角色名称
        :param search_EQ_roleType: 角色类型
        :return:
        '''
        data = {
        'curPage':curPage,
        'maxSize':maxSize,
        'search_LIKE_name':search_LIKE_name,
        'search_EQ_roleType':search_EQ_roleType
        }
        req = Request(ServerUrl.role_getpage_url,params=data,headers=cookie)
        return req.get()

    @classmethod
    def grantpower(cls,roleIdAndMenuId,cookie):
        '''角色关联菜单'''
        data = {
            'roleIdAndMenuId':roleIdAndMenuId
        }
        req = Request(ServerUrl.role_grantpower_url,params=data,headers=cookie)
        return req.post()

    @classmethod
    def per_saveuserreason(cls,type,userId,ids,cookie):
        '''个人监管权限'''
        data = {
            'type':type,
            'userId':userId,
            'ids':ids
        }
        req = Request(ServerUrl.role_per_saveuserreason_url,params=data,headers=cookie)
        return req.post()

    @classmethod
    def ent_saveuserreason(cls, type, userId, ids, cookie):
        '''企业监管权限'''
        data = {
            'type': type,
            'userId': userId,
            'ids': ids
        }
        req = Request(ServerUrl.role_ent_saveuserreason_url, params=data, headers=cookie)
        return req.post()












if __name__ == "__main__":
    pass